//
//  DocSelectionViewController.m
//  Novels
//
//  Created by iajmani on 2/21/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "DocSelectionViewController.h"


@implementation DocSelectionViewController
@synthesize myPicker;
@synthesize myButton;
@synthesize myNoteList;

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
	return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
	return [books count];
	
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
	return [books objectAtIndex:row];
}

-(IBAction)readButtonPressed{
	TextViewController *textVC=[[TextViewController alloc] initWithNibName:@"TextViewController" bundle:nil];
	int index=[myPicker selectedRowInComponent:0];
	textVC.books=[books objectAtIndex:index];
	[self.navigationController pushViewController:textVC animated:YES];  //******Xin Shu******:load the Textview first,load text to textviewcontroller later in DocSelectionViewController

}
	 

// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}.
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	//test Dictionary by Xin Shu, remember to delete
	//[NoteList DictionaryTest];
	
	////-------------------------create----------------------------////

	 myNoteList = [[NoteList alloc] init];
	[myNoteList AddNewNote:@"FirstNote"];
	[myNoteList AddNewNote:@"SecondNote"];
	[myNoteList AddNewNote:@"ThirdNote"];
	NSLog(@"%@", [myNoteList theList]);		
	//NSString *documentDirectoryPath = [Utilities getFilename];
	
	books = [myNoteList.theList allKeys];
	[books retain];
	//books = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Books" ofType:@"plist"]];
	
	

}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
